home *** CD-ROM | disk | FTP | other *** search
- Path: news.kiss.de!news
- From: demler@kiss.de (Scott M. Demler)
- Newsgroups: comp.lang.c
- Subject: Re: extern and static are they compatable
- Date: Fri, 05 Jan 1996 23:26:08 GMT
- Organization: KISS Kaiserslautern Internet Solution Service
- Message-ID: <4ckd75$i14@phobos.kiss.de>
- References: <4cedhf$g6i@cnn.cc.biu.ac.il> <ahicksDKM8Ap.FBp@netcom.com>
- NNTP-Posting-Host: dialin10.kiss.de
- X-Newsreader: Forte Free Agent 1.0.82
-
- ahicks@netcom.com (Aaron Hicks at Netcom) wrote:
-
- >Folks,
-
- > I'm working on a project which requires use to create large array
- >( approximately 500 K bytes ) so we decided to make it static so it would
- >not have be created each time the routines that use it are called. We then
- >found out that we needed a nother program to acess this array so in the second
- >file we defined this array as a extern. Now each time we compile and link
- >the programs we get an error stating that the array is undefined. The error
- >is displayed while linking. After reading all I could find about extern
- >I can not find any thing that says this is correct behavior. I then changed
- >the static decloration to a non static and the thing compiles with out a
- >problem. Now I'm wandering if any of the great mind on the net could
- >enlighten me as to why the static declaration would cause this error.
- >Below is a short part of the code that shows the declarations of the array.
-
- >header_file.h
- >...
-
- >typedef char Bit_Fail_Array_Type[Row_Max][Column_Max_By_Byte][Sub_Array_Max];
- >...
-
- >raster.c
- >...
- >/* Global declaration of the array to hold the failed bits */
- >static Bit_Fail_Array_Type bit_fail_array_table;
- >...
-
- >raster_analysis.c
- >...
- >/* Declare the array that hold the failed bits to analysis */
- >extern Bit_Fail_Array_Type bit_fail_array_table;
- >...
-
-
- >Thanks in Advance and Happy New Year
-
- >Aaron Hicks
- >ahicks@netcom.com
-
- Aaron,
-
- In brief... Objects declared static can only be accessed from within the same
- 'source file'. To access an object from somewhere outside of the source file
- you must declare it extern.
-
- :-) Scott M. Demler
-
-